import {ACTION_PERMISSION} from './action'
import initState from './state'
import {PERMISSION} from '../util/WtConst'

export default (state = initState.permission,action) => {
    switch(action.type){
        case ACTION_PERMISSION.UPDATE_PERMISSION:
            const {permission} = action.payload;
            return {
                // taskAdd:permission.indexOf(PERMISSION.TASK_ADD)>=0,
                // selfProject:permission.indexOf(PERMISSION.SELF_PROJECT)>=0,
                // selfTask:permission.indexOf(PERMISSION.SELF_TASK)>=0,
                companyProject:permission.indexOf(PERMISSION.PROJECT_MANAGE)>=0,
                companyTemplate:permission.indexOf(PERMISSION.TEMPLATE_MANAGE)>=0,
            };
        default:
            return state;
    }
}